package net.atomarrow.util.bean;

import java.util.Date;


public class MonthBean implements Option{

	private int year;
	private int month;
	private Date startDay;
	private Date endDay;
	private Date cycleStartDay;
	private Date cycleEndDay;
	

	public MonthBean(int year, int month, Date thisMonthFirstDay,
			Date thisMonthLastDay) {
		this.year=year;
		this.month=month;
		this.startDay=thisMonthFirstDay;
		this.endDay=thisMonthLastDay;
	}
	public int getYear() {
		return year;
	}
	public void setYear(int year) {
		this.year = year;
	}
	public int getMonth() {
		return month;
	}
	public void setMonth(int month) {
		this.month = month;
	}
	/**
	 * 月第一天
	 * @return
	 */
	public Date getStartDay() {
		return startDay;
	}
	public void setStartDay(Date startDay) {
		this.startDay = startDay;
	}
	/**
	 * 月最后一天
	 * @return
	 */
	public Date getEndDay() {
		return endDay;
	}
	public void setEndDay(Date endDay) {
		this.endDay = endDay;
	}
	
	public Date getCycleStartDay() {
		return cycleStartDay;
	}
	public void setCycleStartDay(Date cycleStartDay) {
		this.cycleStartDay = cycleStartDay;
	}
	public Date getCycleEndDay() {
		return cycleEndDay;
	}
	public void setCycleEndDay(Date cycleEndDay) {
		this.cycleEndDay = cycleEndDay;
	}
	/**
	 * 如果开始时间在周期开始时间之前则返回周期的开始时间，否则返回开始时间
	 * @return
	 */
	public Date getStartDayClever() {
		if(cycleStartDay!=null&&cycleStartDay.after(startDay)){
			return cycleStartDay;
		}
		return startDay;
	}
	/**
	 * 如果结束时间在周期结束时间之后则返回周期的截止时间，否则返回结束时间
	 * @return
	 */
	public Date getEndDayClever() {
		if(cycleEndDay!=null&&cycleEndDay.before(endDay)){
			return cycleEndDay;
		}
		return endDay;
	}
	@Override
	public Object getOptionValue() {
		return month;
	}
	@Override
	public Object getOptionText() {
		return month+"月份";
	}
	
}
